import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:leader_help/utils/component/component.dart';
import 'package:leader_help/utils/component/list/table_view.dart';
import 'package:leader_help/utils/util.dart';

import 'index.dart';
import 'widgets/widgets.dart';

class AddPointPage extends GetView<AddPointController> {
  const AddPointPage({Key? key}) : super(key: key);

  // 内容页
  Widget _buildView() {
    return TableView(
      data: controller.state.list,
      padding: EdgeInsets.all(10.r),
      footer: GestureDetector(
        onTap: controller.actionAdd,
        child: Container(
          margin: EdgeInsets.symmetric(vertical: 15.r),
          height: 40.r,
          alignment: Alignment.center,
          decoration: BoxDecoration(
            color: Colors.white,
            border: Border.all(color: ColorsUtil.content, width: 0.5),
          ),
          child: Text(
            '+ 继续添加',
            style: pfMediumStyle(color: ColorsUtil.red, fontSize: 15.sp),
          ),
        ),
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return GetBuilder<AddPointController>(
      builder: (_) {
        return Scaffold(
            appBar: detailAppBar(
              context,
              title: '添加我的重点',
              bottom: PreferredSize(
                child: Container(
                  height: 50.r,
                  decoration: const BoxDecoration(
                      color: ColorsUtil.bg,
                      border: Border(bottom: BorderSide(color: Colors.white))),
                  alignment: Alignment.center,
                  child: Text(
                    '添加后即可在“我的重点”模块跟踪任务问题与进度',
                    style: pfSCStyle(color: ColorsUtil.green, fontSize: 15.sp),
                  ),
                ),
                preferredSize: Size.fromHeight(50.r),
              ),
            ),
            body: Padding(
              padding: EdgeInsets.only(bottom: 50.r + SizeFit.safeBottom),
              child: _buildView(),
            ),
            bottomSheet: Row(
              children: [
                Expanded(
                  child: GestureDetector(
                    onTap: Get.back,
                    child: Container(
                      margin: EdgeInsets.only(bottom: SizeFit.safeBottom),
                      decoration: BoxDecoration(
                          border: Border.all(color: ColorsUtil.red)),
                      height: 50.r,
                      alignment: Alignment.center,
                      child: Text(
                        '取消',
                        style: pfMediumStyle(
                            color: ColorsUtil.title, fontSize: 15.sp),
                      ),
                    ),
                  ),
                ),
                Expanded(
                  child: GestureDetector(
                    onTap: controller.actionSure,
                    child: Container(
                      margin: EdgeInsets.only(bottom: SizeFit.safeBottom),
                      color: ColorsUtil.red,
                      height: 50.r,
                      alignment: Alignment.center,
                      child: Text(
                        '确认添加',
                        style:
                            pfMediumStyle(color: Colors.white, fontSize: 15.sp),
                      ),
                    ),
                  ),
                ),
              ],
            ));
      },
    );
  }
}
